package com.qfedu.controller;

import com.qfedu.entity.Consumer;
import com.qfedu.entity.ResponseData;
import com.qfedu.service.ConsumerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class ConsumerController {

    @Autowired
    private ConsumerService consumerService;


    @RequestMapping
    public List<Consumer> selectcha(){
        return consumerService.selectcha();
    }

    /**
     * 登录
     * @param consumer 封装的用户名及密码
     * @return
     */

    @RequestMapping("/login/status")
    public ResponseData<List<Consumer>> loginIn(Consumer consumer){

        return consumerService.loginIn(consumer);
    }

    /**
     * 注册
     * @param consumer
     * @return
     */
    @RequestMapping("/add")
    public ResponseData<String> SignUp(Consumer consumer){

        return consumerService.SignUp(consumer);
    }

    /**
     * 更新用户信息
     * @param consumer
     * @return
     */
    @RequestMapping("/update")
    public ResponseData<String> updateUserMsg(Consumer consumer){

        return consumerService.updateUserMsg(consumer);
    }

    /**
     * 返回指定ID的用户
     * @param id
     * @return
     */
    @RequestMapping("/detail")
    public List<Consumer> getUserOfId(int id){

        return consumerService.getUserOfId(id);
    }


    @RequestMapping("/delete")
    public boolean deleteshan(int id){
        boolean update = consumerService.deleteshan(id);
        return update;
    }
}

